#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""


class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left, self.right = None, None


class Solution:
    def invertBinaryTree(self, root):
        # write your code here
        self.invert_rec(root)

    # =================== =====================
    def invert_rec(self, node):
        if not node:
            return node

        reverted_left = self.invert_rec(node.left)
        reverted_right = self.invert_rec(node.right)
        print(reverted_left)
        print(reverted_right)
        node.left = reverted_right
        node.right = reverted_left

        return node


def main():
    print("start main")
    root = TreeNode(0)
    left = TreeNode(1)
    right = TreeNode(2)
    root.left = left

    s = Solution()
    s.invertBinaryTree(root)
    print(root.right.val)

if __name__ == "__main__":
    main()
